const EventEmitter = require('events').EventEmitter;

class EventListen extends EventEmitter{
    constructor() {
        super();
        setInterval( () => {
            this.emit('newEvent', { price: Math.floor(Math.random()*100) });
        }, 2000);
    }
}

const Event = new EventListen;
Event.addListener('newEvent', (res) => {
    if(res.price<60){
        console.log(`yeah! It's only $${res.price}, I can try it.`);
    } else{
        console.log(`Oh! It's too expensive!`);
    }
    // eval('console.log("emit")');
})